home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-07 | 4.7 KB | 144 lines | [TEXT/ALFA] |
- #===============================================================================================
- # Create new filesets either by the "Utils:Add Fileset..." menu item. These
- # filesets can be made permanent by "Utils:Dump Fileset..."ing the fileset
- # to immediately below.
- #
- # Alpha calls two fileset-related routines, 'getCurrFileSet', and
- # 'getFileSetNames'. Alpha will also attempt to set the variable 'currFileSet'
- # on occasion, but this isn't critical.
- #===============================================================================================
-
- #===========================================================================
- # The filesets.
- #===========================================================================
-
- # Build some filesets on the fly.
- catch {unset fileSets}
- catch {unset currFileSet}
- catch {set fileSets(HomeDir) [glob -t TEXT $HOME:*]}
- catch {set fileSets(Help) [glob -t TEXT "$HOME:*"]}
- catch {set fileSets(System) [glob -t TEXT "$HOME:Tcl:SystemCode:*.tcl"]}
- catch {set fileSets(User) [glob -t TEXT "$HOME:Tcl:UserCode:*.tcl"]}
-
- catch {set currFileSet [lindex [array names fileSets] 0]}
-
- # Example dumped fileset (these files won't exist on your machine).
- set fileSets(AltHelp) {
- "Internal:Development:Alpha:Help:Alpha Commands"
- "Internal:Development:Alpha:Help:Customizing"
- "Internal:Development:Alpha:Help:Debugging"
- "Internal:Development:Alpha:Help:Default Key Bindings"
- "Internal:Development:Alpha:Help:electricAlias Help"
- "Internal:Development:Alpha:Help:General Help"
- "Internal:Development:Alpha:Help:LaTeX Help"
- "Internal:Development:Alpha:Help:Regular Expressions"
- "Internal:Development:Alpha:Help:Shells"
- "Internal:Development:Alpha:Help:Tcl"
- "Internal:Development:Alpha:Help:Tcl Library - auto-loading"
- "Internal:Development:Alpha:Help:Tcl Mailing List"
- "Internal:Development:Alpha:Help:XTCLs"
- }
-
- # Insert your filesets here...
-
-
-
- #===========================================================================
- # The support routines.
- #===========================================================================
- # Called from Alpha to get list of files for current file set.
- proc getCurrFileSet {} {
- global fileSets
- global currFileSet
- return $fileSets($currFileSet)
- }
-
- # Called from Alpha to get names. The first name returned is taken to
- # be the current fileset.
- proc getFileSetNames {} {
- global fileSets
- global currFileSet
- set ind [lsearch [array names fileSets] $currFileSet]
- if {$ind < 0} {set ind 0}
- return [linsert [lsort [lreplace [array names fileSets] $ind $ind]] 0 $currFileSet]
- }
-
-
- # Keep 'fileSets' menu up to date.
- trace vdelete currFileSet w shadowCurrFileSet
- trace variable currFileSet w shadowCurrFileSet
- proc shadowCurrFileSet {nm1 nm2 op} {
- global fileSets
- global currFileSet
- foreach name [array names fileSets] {
- if {$name == $currFileSet} {
- markMenuItem fileSets $name on
- } else {
- markMenuItem fileSets $name off
- }
- }
- return $currFileSet
- }
-
- # Called in response to user changing filesets from the fileset menu.
- proc changeFileSet {menu item} {
- global fileSetNames
- global currFileSet
-
- set currFileSet $item
- }
-
-
- #===========================================================================
- # Add fileset.
- #===========================================================================
- proc createFileset {} {
- global fileSets
- global currFileSet
-
- set name [getline "New fileset name:" ""]
- if {![string length $name]} return
-
- set dir [get_directory]
- if {![string length $dir]} return
-
- set filePat [getline "File pattern:" "*"]
- if {![string length $filePat]} return
-
- set fileSets($name) [glob "$dir:$filePat"]
- menu -n fileSets -m -p changeFileSet [lsort [array names fileSets]]
- set currFileSet $name
-
- if {[askyesno "Save new fileset?"] == "yes"} {
- addUserLine "set fileSets($name) \[glob -t TEXT \"$dir:$filePat\"\]"
- addUserLine "addMenuItem -m fileSets \"$name\""
- }
- }
-
-
- #===========================================================================
- # Dump fileset to current window. If you dump at the end of this file,
- # the fileset will be reloaded the next time you run Alpha.
- #===========================================================================
- proc dumpFileset {} {
- global fileSets
- global currFileSet
- if {![catch {prompt "Fileset name:" $currFileSet} name]} {
- insertText "set fileSets(" $name ") \{\r"
- foreach file $fileSets($name) {
- insertText "\t\"$file\"\r"
- }
- insertText "\}\r"
- }
- }
-
-
-
- #===========================================================================
- # Must stay the last thing in the file! We need this so that all the
- # filesets defined above make it into the menu.
- #===========================================================================
- menu -n fileSets -m -p changeFileSet [lsort [array names fileSets]]
- markMenuItem fileSets $currFileSet on
-
-